<!-- 修改资源库 -->
<template>
  <mk-inline>
    <mk-button :type="4"
               @click="show()">编辑</mk-button>
    <cmResource-form v-if="visible"
                     :row="row"
                     @close="close"
                     :rstype="rstype"
                     :title="`编辑${config.GlobalMap.RESOURCE[rstype]}`"
                     btn-name="保存"
                     :is-add="false" />
  </mk-inline>
</template>
<script>
import CmResourceForm from './form'
import { MkBase } from 'element-ui'
export default {
  name: 'edit-button',
  mixins: [MkBase],
  components: {
    CmResourceForm
  },
  props: {
    row: Object,
    rstype: String
  },
  data () {
    return {
      visible: false
    }
  },
  methods: {
    show () {
      this.visible = true
    },
    /**
     * 关闭对话框时触发
     * 根据弹框是否需要重载页面而反馈到列表
     */
    close (reload) {
      this.visible = false
      if (reload === true) {
        this.$emit('reload')
      }
    }
  }
}
</script>